package cn.bdqn.mapper;

import cn.bdqn.pojo.SysUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class SysUserMapperTester {
    @Resource
    SysUserMapper sysUserMapper;
    @Test
    public void testSelectById(){
        SysUser sysUser=sysUserMapper.selectById(2l);
        System.out.println(sysUser);
    }
    @Test
    public void testSelectList(){
        List<SysUser> list = sysUserMapper.selectList();
        for (SysUser sysUser : list) {
            System.out.println(sysUser);
        }
    }
    @Test
    public void testInsert(){
        SysUser sysUser=new SysUser();
        sysUser.setUsrName("zhangsan");
        sysUser.setUsrPassword("123456");
        sysUser.setUsrRoleId(1l);
        sysUser.setUsrFlag(1);

        int insert = sysUserMapper.insert(sysUser);
        if (insert>0){
            System.out.println("新增成功");
        }
        System.out.println("新增失败");
    }
    @Test
    public void testUpdate() {
        SysUser sysUser = new SysUser();
        sysUser.setUsrId(18L);
        sysUser.setUsrName("lisi");
        sysUser.setUsrPassword("888888");
        sysUser.setUsrRoleId(2L);
        sysUser.setUsrFlag(0);
        int result = sysUserMapper.update(sysUser);
        if (result > 0) {
            System.out.println("修改成功");
        } else {
            System.out.println("修改失败");
        }

    }
    @Test
    public void testDelete(){
        int result =sysUserMapper.delete(18L);
        if(result>0){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }
}
